package com.example.demo.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.time.LocalDate;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Table
@Entity
//@DynamicUpdate
@EntityListeners(AuditingEntityListener.class)
public class Account {
    private static int i = 0;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private  Integer accountNumber;

    private String accountName/*="订单名字"+i++*/;


    private double balance=0;

    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @CreatedDate
    @Column(updatable = false)
    private LocalDate openingDate;

    @JoinColumn(name="customerId")
    @ManyToOne
    private  Customer customer;


    public Account(double balance) {
        this.balance = balance;
    }
}
